Bidirectional Coroutines
نویسنده
چکیده
The bidirectional coroutine is introduced as a mechanism for overcoming a shortcoming in the method of specification of the transfer of control between coroutines. An analogy is drawn between subroutines and coroutines by observing that coroutines, like subroutines, should not have to know with whom they are interacting. At present, most coroutine implementations require specific mention of the coroutine being resumed, or use a s u s p e n d mechanism in which case one coroutine acts as a slave (the suspending one) and the other as a master. In the second case, the slave need not know the identity of its master while the master must know the identity of its slave. For bidirectional coroutines, a coroutine need not know the identity of its master nor its slave. This is achieved by replacing the s u s p e n d primitive with two new primitives r e sume_mas te r and resume_ slave.
منابع مشابه
Christian - Albrechts - Universität Kiel
1 A coroutine is a programming construct between function and thread. It behaves like a function that can suspend itself arbitrarily often to yield intermediate results and to get new inputs before returning a result. This facility makes coroutines suitable for implementing generator abstractions. Languages that support coroutines are often untyped or they use trivial types for coroutines. This...
متن کاملTyping Coroutines
A coroutine is a programming construct between function and thread. It can be invoked like a function, but before it returns a value (if ever) it may suspend itself arbitrarily often to return intermediate results and then be resumed with new inputs. Unlike with preemptive threading, a coroutine does not run concurrently with the rest of the program, but rather takes control until it voluntaril...
متن کاملCoroutines in Lua
After a period of oblivion, a renewal of interest in coroutines is being observed. However, most current implementations of coroutine mechanisms are restricted, and motivated by particular uses. The convenience of providing true coroutines as a general control abstraction is disregarded. This paper presents and discusses the coroutine facilities provided by the language Lua, a full implementati...
متن کاملDeriving Type Systems and Implementations for Coroutines
Starting from reduction semantics for several styles of coroutines from the literature, we apply Danvy’s method to obtain equivalent functional implementations (definitional interpreters) for them. By applying existing type systems for programs with continuations, we obtain sound type systems for coroutines through the translation. The resulting type systems are similar to earlier hand-crafted ...
متن کاملA verified abstract machine for functional coroutines
Functional coroutines are a restricted form of control mechanism, where each coroutine is represented with both a continuation and an environment. This restriction was originally obtained by considering a constructive version of Parigot’s classical natural deduction which is sound and complete for the Constant Domain logic. In this article, we present a refinement of de Groote’s abstract machin...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
- Inf. Process. Lett.
دوره 21 شماره
صفحات -
تاریخ انتشار 1985